import React, { Component } from 'react'
import {connect} from 'react-redux'
import {SELECT_ALL} from '../store/types'
class Footer extends Component {
  render() {
    return (
      <div className='footer'>
        <div>
            <input type="checkbox" onChange={(e)=>{
              // console.log(e.target.checked);
              this.props.changeAll(e.target.checked)
            }} checked={this.props.isAll} /> 全选
        </div>
        <span> {this.props.selectCount} / {this.props.todoList.length} </span>
      </div>
    )
  }
}

export default connect((state)=>{
  return {
    todoList: state.todo.todoList,
    selectCount: state.todo.selectCount,
    isAll: state.todo.isAll
  }
}, (dis)=>{
  return {
    changeAll(val){
      dis({type: SELECT_ALL, payload: val})
    }
  }
})(Footer)